package com.example.designPattern.singleton;



//懒汉模式-双检锁  兼顾线程安全和效率的写法
public class BadmashDoubleLockSingleton {
    private volatile static  BadmashDoubleLockSingleton instance;
    private BadmashDoubleLockSingleton(){
    }
    public static BadmashDoubleLockSingleton getInstance(){
        if(instance == null){
            synchronized(BadmashDoubleLockSingleton.class){
                if(instance == null){
                    // 延迟创建加载
                    instance = new BadmashDoubleLockSingleton();
                }
            }
        }
        return instance;
    }

}
